<?php
namespace app\pay\controller\common;

use think\Controller;
use customtool\Utils;
/*
 * 代付中转接口
 */

class Daifu extends Base {
    /*
     * 客户端向畅远管理后台发起代付申请
     */
    public function apply() {
        $data = input('post.');
        $mod = array( // 必传参数
            0 => 'merchant_id',
            1 => 'mchnt_batchid',
            2 => 'mchnt_orderid',
            3 => 'amount',
            4 => 'account_name',
            5 => 'account_number',
            6 => 'bank_code',
            7 => 'signature'
        );
        $resParams = Utils::checkParamsExists($data, $mod, null);
        if($resParams) {
            // 根据商户号获取商户相关信息
            $resPayBis = model('PayBis')->get(['merchant_id' => $data['merchant_id']]);
            if($resPayBis) {
                $DaifuApply = new DaifuApply();
                $result = $DaifuApply->apply($data, $resPayBis);
                return $result;
            } else {
                // 商户号不存在
                return paymchntIdFalse();
            }  
        } else {
            return $resParams;
        }
    }
    
    /*
     * 客户端向畅远管理后台发起代付余额查询
     */
    public function yuE() {
        $DaifuYuE = new DaifuYuE();
        $result = $DaifuYuE->index();
        return $result;
    }
    
    /*
     * 客户端向畅远管理后台发起代付订单查询
     */
    public function query() {
        $DaifuQuery = new DaifuQuery();
        $result = $DaifuQuery->index();
        return $result;
    }
}

